﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;
using System.Threading.Tasks;

namespace bChatServer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            bChatServerDAL.ServerLog.ServerLogHookEvent += new bChatServerDAL.ServerLog.ServerLogHookEventHandler(ServerLog_ServerLogHookEvent);

            Task AppMain = new Task(delegate { ApplicationController.Init(); });

            AppMain.Start();

            //logger hook
            
            
        }

        void ServerLog_ServerLogHookEvent(object sender, bChatServerDAL.ServerLogHookEventArgs e)
        {
            try
            {
                mydelegate d = new mydelegate(mymethod);
                listBox1.Invoke(d,e.ToString());

                

            }
            catch (Exception ex)
            {
                ex = ex;
            }
        }

        private delegate void mydelegate(string param);

        private void mymethod(string param)
        {
            listBox1.Items.Add(param);
        }



        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
    }
}
